package message

import (
	"context"
	"git.mycaigou.com/gfyx/common/rpc_client"
	"git.mycaigou.com/gfyx/micro-gfyx-mp-api/infrastructure/common/constants"
	pb "git.mycaigou.com/gfyx/micro-gfyx-mp-api/proto/micro_gfyx_user_service_proto/micro-gfyx-user-service"
)

type verifyCodeRepository struct {
}

// NewVerifyCodeRepository 构造函数
func NewVerifyCodeRepository() VerifyCodeRepositoryIface {
	return &verifyCodeRepository{}
}

func (r *verifyCodeRepository) SendSmsCode(ctx context.Context, request *pb.SendSmsRequest) (*pb.SendSmsResponse, error) {
	conn, ctx, err := rpc_client.GetClientConn(ctx, constants.MICRO_GFYX_USER_SERVICE)
	if err != nil {
		return nil, err
	}
	defer func() {
		_ = conn.Close()
	}()
	client := pb.NewVerifyCodeServiceClient(conn)
	return client.SendSms(ctx, request)
}
